<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>卡片列表</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        .card-list {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            justify-content: center;
        }
        .card {
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            width: calc(25% - 20px);
            transition: transform 0.3s ease;
        }
        .card:hover {
            transform: translateY(-10px);
        }
        .card img {
            width: 100%;
            height: 200px;
            object-fit: cover;
        }
        .card-content {
            padding: 20px;
        }
        .card-title {
            font-size: 24px;
            margin: 0;
            color: #333;
        }
        .card-description {
            font-size: 16px;
            color: #666;
            margin-top: 10px;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>卡片列表</h1>
    <div class="card-list" id="cardList"></div>
</div>

<script>
    document.addEventListener('DOMContentLoaded', function() {
        fetch('data.json') // 确保JSON文件与HTML文件在同一目录下
            .then(response => response.json())
            .then(data => {
                const cardListContainer = document.getElementById('cardList');
                data.forEach(card => {
                    const cardElement = document.createElement('div');
                    cardElement.className = 'card';
                    cardElement.innerHTML = `
                        <img src="${card.imageUrl}" alt="${card.title}">
                        <div class="card-content">
                            <h2 class="card-title">${card.title}</h2>
                            <p class="card-description">${card.description}</p>
                        </div>
                    `;
                    cardListContainer.appendChild(cardElement);
                });
            })
            .catch(error => console.error('Error loading the JSON file:', error));
    });
</script>
</body>
</html>